package com.ai.web.interceptor;

import java.util.Enumeration;
import java.util.HashMap;
import java.util.Map;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import org.springframework.web.servlet.handler.HandlerInterceptorAdapter;

import com.ai.web.cache.Constants;
import com.ai.web.util.Utils;

public class QueryInterceptor  extends HandlerInterceptorAdapter{  
    
	@Override  
    public boolean preHandle(HttpServletRequest request,  
            HttpServletResponse response, Object handler) throws Exception {  
        
		
		Map<String, Object> paramMap = new HashMap<String, Object>();
		
		Enumeration<?> enu = request.getParameterNames();
		while (enu.hasMoreElements()) {
			Object obj = enu.nextElement();
			if (obj != null) {
				String param = obj.toString();
				String val = request.getParameter(param);
				if (Utils.isEmpty(val)) {
					continue;
				}
				paramMap.put(param, val);
			}
		}
		
		Object user = request.getSession().getAttribute(Constants.USER_CONTEXT);
		System.out.println("---- session user=" + user);
		
    	
    	return true;
    }  
}  

